<?

//Initiate Authenticate
SecurityRedirect ();

//initiate Vars 
define("PRIMARY_KEY","skada");
$KEY[]         = array("PRIMARY_KEY"=>PRIMARY_KEY);
$FileName      = "ais_report_setup_receipt.php";
$FileTemplate  = "ais_report_setup_receipt_list.html";
$TableName     = "tblreceipt";
$SubHeaderTitle= "Report Setup Receipt";
$PageSize      = 10 ;
$HTMLGridList  = "receiptGrid";

//Initiate Database Table For Search;
$FNama = GetParam("namaSearch","");
$FCode = GetParam("codeSearch","");

//******* DATABASE FORM QUERY ***********
$SQL = "SELECT *, IF(kdtype=0,'Return','Closed') as type FROM `$TableName` ";
$SQLCount = "SELECT count(*) FROM `$TableName` ";

if ($FNama) 
	if (strlen($WHERE)) $WHERE .= " AND "." receiptname like '".$FNama."%'";
	else $WHERE .= " receiptname like '".$FNama."%'";	
if ($FCode) 
	if (strlen($WHERE)) $WHERE .= " AND "." kdreceipt like '".$FCode."%'";
	else $WHERE .= " kdreceipt like '".$FCode."%'";

	if (strlen($WHERE))	$WHERE = " WHERE ".$WHERE;
	else $WHERE = " WHERE 1";

$SQL = $SQL.$WHERE;
$SQLCount = $SQLCount.$WHERE;
$SQL = $SQL." ORDER BY kdreceipt";

//******* SHOW FORM CONTENT *********
$PageNum = 1;
$RecCnt = $DBConnection->GetResSQL($SQLCount) ; 

if (GetParam("PageNum","")) $PageNum  = GetParam("PageNum","");

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate($MOD_TEMPLATE_DIR."/".$FileTemplate);
$TBS->MergeBlock("bln",$KEY);
$TBS->MergeBlock("blg",$DBMysql,$SQL,$PageSize,$PageNum,$RecCnt);


$TBS->MergeNavigationBar('nv',array('size'=>10,'pos'=>'centred'),$PageNum,$RecCnt,$PageSize) ; 
$TBS->Show();


?>